#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main()
{
    int n;
    scanf("%d", &n);
    getchar();

    while (n--)
    {
        char w[21];
        scanf("%s", w);

        int first = isdigit(w[0]);
        if (first)
        {
            printf("INVALID\n");
            continue;
        }
        else
        {
            int len = strlen(w);
            int i = 0;
            for (i = 0; i < len; i++)
            {
                if (w[i] == '_')
                    continue;
                int x = isdigit(w[i]);
                int y = isalpha(w[i]);
                if (x == 0 && y == 0)
                {
                    printf("INVALID\n");
                    break;
                }
            }
            if (i == len)
                printf("VALID\n");
        }
    }
    return 0;
}